SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")

add_definitions(-W -Wextra -Wall -Wsign-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers)
add_definitions(-fno-builtin-memcmp -msse -msse4.2 -fno-omit-frame-pointer -DNDEBUG -momit-leaf-frame-pointer)
add_definitions(-D_GNU_SOURCE -fno-omit-frame-pointer -DNDEBUG -pipe -fPIC -pg)

#EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb ${CMAKE_CURRENT_BINARY_DIR}/rocksdb)
#EXECUTE_PROCESS(COMMAND chmod 755 ${CMAKE_CURRENT_BINARY_DIR}/rocksdb/build_tools/build_detect_platform)
#EXECUTE_PROCESS(COMMAND chmod 755 ${CMAKE_CURRENT_BINARY_DIR}/rocksdb/build_tools/version.sh)
#if (EXISTS ${CMAKE_BINARY_DIR}/third/rocksdb/librocksdb.a)
#else()
#    message("make librocksdb.a")
#    set(SHELL_SH "make -j -C ${CMAKE_CURRENT_BINARY_DIR}/rocksdb static_lib DISABLE_JEMALLOC=1")
#    execute_process(COMMAND bash -c ${SHELL_SH})
#endif()

execute_process(COMMAND date "+%Y/%m/%d %H:%M:%S" OUTPUT_VARIABLE DATETIME)
#string(REGEX REPLACE "\n" "" DATETIME ${DATETIME})
set(GIT_DATE_TIME "${DATETIME}")
set(GIT_SHA 0)

configure_file(slash/slash/src/build_version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/slash/build_version.cc @ONLY)
configure_file(pink/pink/src/build_version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/pink/build_version.cc @ONLY)
configure_file(blackwidow/src/build_version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/blackwidow/build_version.cc @ONLY)

include_directories(
        ${PROJECT_BINARY_DIR}
        ${PROJECT_SOURCE_DIR}/third/slash
        ${PROJECT_SOURCE_DIR}/third/pink
        ${PROJECT_SOURCE_DIR}/third/nemo-rocksdb
        ${PROJECT_SOURCE_DIR}/third/nemo-rocksdb/include
        ${PROJECT_SOURCE_DIR}/third/rocksdb
        ${PROJECT_SOURCE_DIR}/third/rocksdb/include
        ${PROJECT_SOURCE_DIR}/third/nemo/include
)
link_directories(
        ${PROJECT_SOURCE_DIR}/lib
        ${PROJECT_BINARY_DIR}/third/slash/slash/lib
        ${PROJECT_BINARY_DIR}/third/pink/pink/lib
        ${PROJECT_BINARY_DIR}/third/rocksdb
        ${PROJECT_BINARY_DIR}/third/nemo-rocksdb/lib
)

aux_source_directory(${CMAKE_CURRENT_BINARY_DIR}/slash SLASH_GEN)
aux_source_directory(slash/slash/src SLASH_SRC)
add_library(slash STATIC ${SLASH_GEN} ${SLASH_SRC})
aux_source_directory(${CMAKE_CURRENT_BINARY_DIR}/pink PINK_GEN)
aux_source_directory(pink/pink/src PINK_SRC)
add_library(pink STATIC ${PINK_GEN} ${PINK_SRC})

aux_source_directory(${CMAKE_CURRENT_BINARY_DIR}/blackwidow BLACKWIDOW_GEN)
aux_source_directory(blackwidow/src BLACKWIDOW_SRC)
add_library(blackwidow STATIC ${BLACKWIDOW_GEN} ${BLACKWIDOW_SRC})


